/* 顶点数组 */
class VertexArray{
	constructor(gl){
		this.gl = gl;
		const vao = gl.createVertexArray();
		this.object = vao;
	}
	
	bind(){
		this.gl.bindVertexArray(this.object);
		return this;
	}
	
	unbind(){
		this.gl.bindVertexArray(null);
		return this;
	}
	
	//安全绑定
	bindSafe(func){
		//保存状态
		const bindingVertexArray = this.gl.getParameter(this.gl.VERTEX_ARRAY_BINDING);
		//改变状态
		this.gl.bindVertexArray(this.object);
		func();
		//恢复状态
		this.gl.bindVertexArray(bindingVertexArray);
		return this;
	}
}
